﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace XthTicketDesktop
{
    /// <summary>
    /// ShowListPage.xaml 的交互逻辑
    /// </summary>
    public partial class ShowListPage : Page
    {
        public ObservableCollection<Performance> Performances { get; set; }

        public ShowListPage()
        {
            InitializeComponent();
            DataContext = this;
            LoadData();
        }

        private void LoadData()
        {
            List<Performance> performances = new List<Performance>
            {
                new Performance { Id = 1, Title = "铜梁龙文化演出", Price = "68元-588元", ImageSource = new Uri("/images/img.png", UriKind.Relative) },
                new Performance { Id = 2, Title = "演出2", Price = "68元-588元", ImageSource = new Uri("/images/img.png", UriKind.Relative) },
                new Performance { Id = 2, Title = "演出2", Price = "68元-588元", ImageSource = new Uri("/images/img.png", UriKind.Relative) },
                
            };
            PerformanceListView.ItemsSource = performances;
        }

        private void BackButton_Click(object sender, RoutedEventArgs e)
        {
            if (NavigationService.CanGoBack)
            {
                NavigationService.GoBack();
            }
        }

        private void DetailsButton_Click(object sender, RoutedEventArgs e)
        {
            if (sender is Button button && button.CommandParameter is int id)
            {
                // 导航到详情页面，传递演出ID作为参数
                NavigationService.Navigate(new Uri($"/ShowDetailPage.xaml?id={id}", UriKind.Relative));
            }
        }
    }

    public class Performance
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public string Price { get; set; }
        public Uri ImageSource { get; set; }
    }
}
